package com.zlll.winner.service.sysUser;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zlll.winner.business.model.sysUser.SysUserRole;
import com.zlll.winner.enums.CommonEnum;
import com.zlll.winner.mapper.sysUser.SysUserRoleMapper;
import com.zlll.winner.business.service.sysUser.ISysUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ricky
 * @since 2019-09-06
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {

    @Autowired
    private SysUserRoleMapper sysUserRoleMapper;

    /**
     * 获取用户拥有的角色
     * @param userId
     * @return
     */
    public List<SysUserRole> getSysUserRoleByUserId(Long userId){
        QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.eq("is_del", CommonEnum.DelEnum.UNDEL.val());
        return sysUserRoleMapper.selectList(queryWrapper);
    }
}
